package 种花605

import scala.+:
import scala.collection.mutable

/**
 * ToDo
 *
 * @author: liuzhixin
 * @date: 2021/5/7,8:46
 * @project_name:LeetCode
 */
object CCC {

  def canPlaceFlowers(flowerbed: Array[Int],n:Int): Boolean = {
    val newarray: Array[Int] = 0 +: flowerbed :+0
    newarray.foreach(print)
    var m = n
    for (i <- Range(1, newarray.length - 1)) {
      if (newarray(i - 1) == 0 && newarray(i) == 0 && newarray(i + 1) == 0) {
        newarray(i) = 1
        m = m-1
      }
    }
    m <= 0
  }
  def main(args: Array[String]): Unit = {
        val array = Array(1,1,1,1,1)
        val n=1
    val bool: Boolean = canPlaceFlowers(array, n)
    println(bool)
  }
}
